package com.ds.dsm.view.nav.service;

import com.ds.config.ResultModel;
import com.ds.dsm.view.config.gallery.GalleryInfoGroup;
import com.ds.esd.custom.api.annotation.APIEventAnnotation;
import com.ds.esd.custom.enums.CustomMenuItem;
import com.ds.esd.custom.module.annotation.ModuleAnnotation;
import com.ds.esd.custom.nav.annotation.NavGroupViewAnnotation;
import com.ds.esd.tool.ui.enums.Dock;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/dsm/view/config/gallery/group/")
public class ViewGalleryConfigService {

//
//    @RequestMapping(method = RequestMethod.POST, value = "ViewTreeFieldConfig")
//    @ModuleAnnotation(dynLoad = true, caption = "获取字段列", imageClass = "bpmfont bpmgongzuoliuxitongpeizhi", index = 0)
//    @APIEventAnnotation(bindMenu = CustomMenuItem.loadChild)
//    @ResponseBody
//    public TreeListResultModel<List<ViewConfigTree>> getViewGridFieldConfig(String domainId, String sourceClassName, String methodName, String viewInstId) {
//        TreeListResultModel<List<ViewConfigTree>> result = new TreeListResultModel<>();
//        try {
//            ViewEntityConfig classConfig = DSMFactory.getInstance().getViewManager().getViewEntityConfig(sourceClassName, domainId, viewInstId);
//            ApiClassConfig customESDClassAPIBean = classConfig.getSourceConfig();
//            MethodConfig methodAPIBean = customESDClassAPIBean.getMethodByName(methodName);
//            CustomTreeViewBean viewBean = (CustomTreeViewBean) methodAPIBean.getView();
//            List<String> fieldNames = viewBean.getFieldNames();
//            List<FieldFormConfig> fieldFormConfigs = new ArrayList<>();
//            for (String fieldName : fieldNames) {
//                FieldFormConfig fieldFormConfig = (FieldFormConfig) viewBean.getFieldConfigMap().get(fieldName);
//                if (fieldFormConfig != null) {
//                    fieldFormConfigs.add(fieldFormConfig);
//                }
//            }
//            result = TreePageUtil.getTreeList(fieldFormConfigs, ViewConfigTree.class);
//        } catch (JDSException e) {
//            e.printStackTrace();
//        }
//        return result;
//    }

    @RequestMapping(method = RequestMethod.POST, value = "GalleryInfoGroup")
    @NavGroupViewAnnotation(reSetUrl = "clear", saveUrl = "updateGalleryConfig", autoSave = true)
    @ModuleAnnotation(dock = Dock.fill, index = 0, caption = "基础信息", imageClass = "spafont spa-icon-project")
    @APIEventAnnotation(bindMenu = CustomMenuItem.treeNodeEditor)
    @ResponseBody
    public ResultModel<GalleryInfoGroup> getGalleryInfoGroup(String sourceClassName, String methodName, String domainId, String viewInstId) {
        ResultModel<GalleryInfoGroup> result = new ResultModel<GalleryInfoGroup>();
        return result;

    }


}
